<?php


namespace app\proxy;


class RuntimeProxy
{
    /**
     * @var Runtime
     */
    private $runTime;

    private $obj;

    public function __construct($obj)
    {
        $this->runTime = new Runtime();
        $this->obj = $obj;
    }

    public function __call($methodName, $args)
    {
        $refection = new \ReflectionClass($this->obj);
        $startTime = microtime(true);
        $method = $refection->getMethod($methodName);
        $result = $method->invoke($this->obj, $args[0]);
        $endTime = microtime(true);
        echo $this->runTime->getRuntime($startTime, $endTime) . "<br>";
        return $result;

    }
}